import requests

def get_robots_txt(url):
    if not url.startswith('http'):
        url = 'https://' + url

    if url.endswith('/'):
        url = url[:-1]

    robots_url = url + '/robots.txt'

    try:
        response = requests.get(robots_url)
        if response.status_code == 200:
            print(f"成功获取 {robots_url}")
            return response.text
        else:
            print(f"无法获取robots.txt，状态码: {response.status_code}")
            return None
    except Exception as e:
        print(f"发生错误: {e}")
        return None